<template>
  <div>
      <div class="ding">
        <div>数据列表</div>
         <el-button class="click1"> 添加</el-button>
     </div>
       <div class="product_con">
      商品列表
     <el-table :data="cateList" border style="width: 100%">
      <el-table-column prop="id" label="编号"> </el-table-column>
      <el-table-column prop="name" label="品牌名称"> </el-table-column>
      <el-table-column prop="first_letter" label="品牌首字母"> </el-table-column>
      <el-table-column prop="sort" label="排序"> 
        <el-switch
              v-model="value"
              active-color="#13ce66"
              inactive-color="#ff4949">
            </el-switch>
      </el-table-column>
      <el-table-column prop="sort" label="排序"> 
        <el-switch
            v-model="value"
            active-color="#13ce66"
            inactive-color="#ff4949">
          </el-switch>
      </el-table-column>
       <el-table-column  label="相关"> 
         商品:100 <br>
         评价:1000
       </el-table-column>
      
      <el-table-column  label="操作" > 
           <div class="click" slot-scope="scope">
           <el-button size="small" @click="editFun(scope.row.id)"
            >编辑</el-button
          >  <el-button type="danger" class="click2" @click="delFun(scope.row.id)">删除</el-button>
           </div>
   </el-table-column>
    </el-table>
     
     <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="listQuery.pageNum"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="listQuery.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>

   </div>
  </div>
</template>

<script>
import { fetchProductcate } from "@/api/product";
export default {
  name: "brand",
    data: function () {
    return {
      cateList: [],
       value: true,
        listQuery:{
        pageSize:5,//一页10条数据
        pageNum:1,//当前页
      },
      total:0
    };
  },
  methods: {
    //获取数据
    async getCateList() {
      const res = await fetchProductcate(this.listQuery);
      console.log(res);
      this.cateList = res.data;
      this.total=res.total
    },
        //修改
    editFun(id) {
      console.log("修改触发了", id);
    },
    //删除
    delFun(id) {
      console.log("删除触发了", id);
    },
      // 修改每页显示的条数
    handleSizeChange(val) {
      console.log("修改每页显示的条数 触发了", val);
      this.listQuery.pageSize = val;
      this.listQuery.pageNum = 1;
      //重新获取数据
    this.getCateList();
    },
    //6.修改当前页的页码
    handleCurrentChange(val) {
      console.log("修改当前页的页码 触发了", val);
      this.listQuery.pageNum = val;
       this.getCateList();
    },
  },
  mounted() {
    this.getCateList();
  },
}

</script>

<style lang="scss" sopend>
.ding{
   width: 99%;
   height:50px ;
   border:1px solid rgb(161, 158, 158);
   margin-left: 10px;
   margin-top: 10px;
   border-radius: 5px;
   display: flex;
   justify-content: space-between;
   div{
      width: 70px;
     height: 24px;
   }
   .click{
     width: 46px;
     height: 24px;
   }
 }
 .product_con{
    margin-left: 10px;
     width: 99%;
 }
 .click{
   width: 400px;
 }
</style>